import { http } from '@/utils/http'
import type { DiskInfo, DiskIOStat } from '@/types/disk'

const API_BASE_URL = '/api'

/**
 * 获取磁盘基本信息和使用情况
 * @returns Promise<DiskInfo[]> 返回磁盘信息数组的Promise对象
 */
export const getDiskInfo = async (): Promise<DiskInfo[]> => {
  return http.get<DiskInfo[]>(`${API_BASE_URL}/disk/info`)
}

/**
 * 获取磁盘IO统计信息
 * @returns Promise<DiskIOStat[]> 返回磁盘IO统计信息数组的Promise对象
 */
export const getDiskIOStats = async (): Promise<DiskIOStat[]> => {
  return http.get<DiskIOStat[]>(`${API_BASE_URL}/disk/io`)
}

/**
 * 获取实时磁盘IO数据（SSE连接）
 * @returns EventSource 返回SSE连接对象
 */
export const getRealTimeDiskIOData = () => {
  return http.createSSE(`${API_BASE_URL}/disk/io/realtime`)
}
